<template>
  <img  :error-icon="defaultimg" :icon-size="`${size}rem`" :style="imgStyle" v-if="src" :src="src" @error="handleError" alt="Image"/>
  <img  :error-icon="defaultimg" :icon-size="`${size}rem`" :style="imgStyle" v-else :src="PCMaterialPic" @error="handleError" alt="Image"/>
</template>
<script setup>
import useConfigStore from '@/store/config'
const configStore = useConfigStore()
const PCMaterialPic = useConfigStore().shopInfo.PCMaterialPic

const props = defineProps({
    // 错误图片大小
    size: {
        type:String,
        default: 0,
    },
    src:{
        type:String,
        default: '',
    }
});
const { size} = toRefs(props);

const imgStyle = computed(() => {
    return {
        width: `${size.value}rem`,
        height:`${size.value}rem`,
    };
});


const imageSrc = ref('');

const handleError = () => {
  imageSrc.value = PCMaterialPic;
};
</script>
<style lang="scss"></style>
